--[[
local a, b = bit.unpacknum(math.sqrt(1.0))

print(bit.tohex(a), bit.tohex(b))

a = a + 1

local f = bit.packnum(a, b)

a, b = bit.unpacknum(f)

print(bit.tohex(a), bit.tohex(b))

print(bit.bsr(0), bit.bsr(16 + 64), bit.bsr(0x80000100))
print(bit.bsf(0x80000100), bit.bsf(16 + 64), bit.bsf(0))
]]

local ctx = serialize.create()

local serialize_getint = serialize.getint
local serialize_getstatus = serialize.getstatus
local yield = coroutine.yield

local test = coroutine.wrap(function()

	local function getint(ctx)
		repeat
			local v = serialize.getint(ctx)
			if serialize_getstatus(ctx) == 0 then return v end
			yield()
		until false
	end

	local function getint2(ctx)
		repeat
			local v = serialize.getint(ctx)
			if v < 0xffffffff then return v end
			yield()
		until false
	end

	for i=1,2000 do
		getint2(ctx)
	end
end)

test()

print("done")